local sk__yaozhan = fk.CreateSkill {

  name = "sk__yaozhan",

  tags = {},

}



sk__yaozhan:addEffect("active", {
  name = "sk__yaozhan",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__yaozhan",
  can_use = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(sk__yaozhan.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and player:canPindian(to_select)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local pindian = player:pindian({ target }, sk__yaozhan.name)
    if pindian.results[target].winner == player then
      if not target.dead then
        room:useVirtualCard("slash", nil, player, target, sk__yaozhan.name, true)
      end
    elseif not player.dead and not target.dead then
      local use = room:askForUseCard(target, "slash", "slash", "#sk__yaozhan-use:" .. player.id, true,
        { exclusive_targets = { player.id }, bypass_times = true })
      if use then
        room:useCard(use)
      end
    end
  end,
})

return sk__yaozhan
